#include "../include/head.h"

// 客户端连接日志
void record_log_connect(int fd_log, int fd_client, const char *msg){
    time_t nowtime;
    time(&nowtime);
    
    char buf[128] = "";
    sprintf(buf, "fd_client = %d:%s\n%s\n", fd_client, msg, ctime(&nowtime));
    write(fd_log, buf, strlen(buf));

}
// 客户端命令日志
void record_log_cmd(int fd_log, int fd_client, pcmd_t pcmd){
    time_t nowtime;
    time(&nowtime);

    char buf[128] = "";
    sprintf(buf, "fd_client = %d:", fd_client);
    for (int i = 0; i < pcmd->argc; i++){
        strcat(buf, pcmd->cmd[i]);
        strcat(buf, " ");
    }
    strcat(buf, "\n");
    strcat(buf, ctime(&nowtime));
    strcat(buf, "\n");
    write(fd_log, buf, strlen(buf));
}
